package com.hz.house.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hz.house.bean.vo.HotQaComment;
import com.hz.house.bean.vo.HotQaCommentReply;
import com.hz.house.service.HotQaService;
import com.hz.house.token.CurrentUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 话题
 * @author lfw
 */
@Api(value = "社区-今日热问板块")
@RestController
@RequestMapping("/api/v2/hotqa")
public class HotQAController {

	@Autowired
	private HotQaService hotQaService;
	
	@ApiOperation(value = "拉取社区首页的三个热问")
	@GetMapping("/get3Hotqa")
	public Object get3Hotqa() {
		return hotQaService.get3Hotqa();
	}
	
	@ApiOperation(value = "获取热问的详情内容")
	@GetMapping("/getHotQaDetail")
	public Object getHotQaDetail(Integer hotQaId) {
		return this.hotQaService.getHotQaDetail(hotQaId,CurrentUser.getCurrentUserId());
	}
	
	@ApiOperation(value = "获取热问的列表，按照时间降序排序")
	@GetMapping("/getHotQaList")
	public Object getHotQaList(Integer page,Boolean myFocus) {
		return this.hotQaService.getHotQaList(page,myFocus,CurrentUser.getCurrentUserId());
	}
	
	@ApiOperation(value = "今日热问添加评论")
	@PostMapping("/addHotqaCmt")
	public Object addHotQaComment(@RequestBody HotQaComment comment) {
		return this.hotQaService.addHotQaComment(CurrentUser.getCurrentUserId(),comment);
	}
	
	@ApiOperation(value = "点赞热问的评论,iHasPraise=1已经点过赞了，此次操作是取消，iHasPraise=0还未点赞，此次操作是点赞")
	@GetMapping("/praiseHotqaCmt")
	public Object praiseHotQaComment(Integer hotqaId,Integer commentId,Integer iHasPraise) {
		return this.hotQaService.praiseHotQaComment(hotqaId, commentId, CurrentUser.getCurrentUserId(),iHasPraise);
	}
	
	@ApiOperation(value = "回复评论或回复别人的回复")
	@PostMapping("/addReplyCmt")
	public Object addReplyOnHotQaComment(@RequestBody HotQaCommentReply reply) {
		return this.hotQaService.addReplyOnHotQaComment(reply,CurrentUser.getCurrentUserId());
	}
	
	@ApiOperation(value = "拉取今日热问的评论和回复数据")
	@GetMapping("/getHotQaCmt")
	public Object getHotQaCommentList(Integer hotQaId,Integer page) {
		return this.hotQaService.getHotQaCommentList(hotQaId, CurrentUser.getCurrentUserId(),page);
	}
	
	@ApiOperation(value = "关注此热问,isHasFoucs=true,已经关注了，本次操作取消，isHasFoucs=false,还未关注，本次操作进行关注")
	@GetMapping("/focusHotqa")
	public Object focusHotQa(Integer hotqaId,Boolean isHasFoucs) {
		return this.hotQaService.focusHotQa(hotqaId, CurrentUser.getCurrentUserId(), isHasFoucs);
	}
	
	@ApiOperation(value = "生成今日热问的海报")
	@GetMapping("/getHotqaBillBase64")
	public Object generateHotQaBillBase64(Integer hotqaId, String customerId) {
		return this.hotQaService.generateHotQaBill(hotqaId, customerId);
	}
}
